package com.example.utils;

import com.isyscore.boot.mqtt.MqttTemplate;
import com.isyscore.boot.mqtt.QoS;

/**
 * @author: cyz
 * @create: 2021/9/1 8:38
 */
public class MqttUtil {

    public static MqttTemplate mqttTemplate;


    public static void send(byte[] data, String topic) {
        mqttTemplate.publishAsync(topic, data, QoS.AT_MOST_ONCE);
    }

    public static boolean isConnected() {
        if (mqttTemplate != null) {
            return MqttUtil.mqttTemplate.isConnected();
        }
        return false;
    }
}
